﻿<!--#include file="const.inc"-->
<%
'====================================================================
' 感谢使用晴天3G智能建站系统..
' 作者:梁永强.QQ:766750857
' 官方网址:wap.qt3g.com
' 声明:软件版权归作者所有,没有经过作者本人同意不得非法破解和传播本程序
'====================================================================
%>
<%
IF  Request.QueryString("Action")="save" Then
	call saves
else
	call indexs
end if
End Function

Function indexs
	dim rs,sql,id,i,we,we0,dao,sou,zi,zi0

select case v
case "0"
we0="<br/>"
hr="-------------<br/>"
%>
<card title="搜索商品"><p align="<%=qingtian.px%>">
<%
case "1"
hr=""
zi="<span style=""color:#FF5500"">"
zi0="</span>"
we="<div class=""footer"">"
sou="<div class=""block4"">"
dao="<div class=""navi"">"
we0="</div>"
%>
<title>搜索商品</title>
</head>
<body>
<!--#include virtual="/css.inc"-->
<%
End Select
if sid="Null" then
%><%=dao%><%=zi%>你还没登录请<%=zi0%><a href="/login.asp?sid=<%=sidd%>&amp;url=/shop/search.asp?id=<%=id%>">登陆</a>后再留览<%=we0%>
<%
else
	qingtian.info
             Response.Write("" & qingtian.qingsav("574") & "" & dao & "搜索|<a href='newli.asp?act=1&amp;sid="&sidd&"'>最新</a>|<a href='newli.asp?act=2&amp;sid="&sidd&"'>热销</a>|<a href='viewshopp.asp?sid="&sidd&"'>购物车</a>" & we0 & "" & hr & "") 	
if v=1 then Response.Write ("<form action=""search.asp?Action=save&amp;sid="&sidd&""" method=""post"">")
        Response.Write (""&sou&"关键字:"&we0&"<input type='text' name='name' value='' size='25'/><br/>")
        Response.Write (""&we&"价格区间:"&we0&"<input type='text' name='mon1' value='0' size='5'/>-<input type='text' name='mon2' value='100000' size='5'/><br/>")
        Response.Write (""&sou&"商品分类:<select name='lied' value='0'><option value='0'>所有分类</option>")
        set rs=Server.CreateObject("ADODB.Recordset")
	Sql = "select [id],[name] from [qingtian_shfeid] order by id desc"
        Rs.Open Sql,conn,1,1
	if not (rs.bof and rs.eof) then
 		For i=1 to rs.RecordCount
		If Rs.Eof Then
			exit For
		End If
        Response.Write ("<option value='"&rs("id")&"'>"&qingtian.utf8(rs("name"))&"</option>")
	 	Rs.MoveNext
	  	Next
        end if
	rs.close
        set rs=nothing
        Response.Write ("</select>")
if v=1 then
        Response.Write ("<input type=""submit"" value=""确定搜索"" />")
else
        Response.Write ("<anchor>确定搜索<go href='search.asp?Action=save&amp;sid="&sidd&"' method='post'><postfield name=""name"" value=""$(name)"" /><postfield name=""lied"" value=""$(lied)"" /></go></anchor>")
end if
        Response.Write we0
end if 
Response.Write("" & qingtian.qingsav("573") & "" & hr & "")    
End Function

Function saves
dim rs,sql,we,we0,dao,sou,zi,zi0,name,lied,errs,mon1,mon2,page

    		Page = Request("page")      '当前页数
    		If Page = "" Then Page = 1
   		If Not IsNumeric(Page) Then Page = 1
    		Page = CLng(Page)
    		If Page < 1 Then Page = 1
        name=qingtian.RepSQL(trim(Request("name")))
        lied=Request("lied")
    		If lied = "" Then lied = -1
   		If Not IsNumeric(lied) Then lied = -1
    		lied = CLng(lied)
        mon1=Request("mon1")
    		If mon1 = "" Then mon1 = -1
   		If Not IsNumeric(mon1) Then mon1 = -1
    		mon1 = CLng(mon1)
        mon2=Request("mon2")
    		If mon2 = "" Then mon2 = -1
   		If Not IsNumeric(mon2) Then mon2 = -1
    		mon2 = CLng(mon2)
        errs=""

set rs=Server.CreateObject("ADODB.Recordset")


select case v
case "0"
we0="<br/>"
Randomize()
book="<input name='Page' format='*N' size='2' maxlength='5'/><anchor>跳页<go href='search.asp?name="&server.URLEncode(name)&"&amp;mon1="&mon1&"&amp;mon2="&mon2&"&amp;lied="&lied&"&amp;run=" & Int((9999) * Rnd() + 1) & "&amp;sid="&sidd&"' method='post'><postfield name=""Page"" value=""$(Page:n)"" /></go></anchor><br/>"
%>
<card title="搜索商品"><p align="<%=qingtian.px%>">
<%
case "1"
hr=""
zi="<span style=""color:#FF5500"">"
zi0="</span>"
we="<div class=""footer"">"
sou="<div class=""block4"">"
dao="<div class=""navi"">"
we0="</div>"
Randomize()
book="<form action=""search.asp?name="&server.URLEncode(name)&"&amp;mon1="&mon1&"&amp;mon2="&mon2&"&amp;lied="&lied&"&amp;run=" & Int((9999) * Rnd() + 1) & "&amp;sid="&sidd&""" method=""post"">"&dao&"<input type=""text"" name=""Page"" value="""" format=""*N"" size=""2"" maxlength=""5""/><input type=""submit"" value=""跳页"" /></form>"
%>
<title>搜索商品</title>
</head>
<body>
<!--#include virtual="/css.inc"-->
<%
End Select
             Response.Write("" & qingtian.qingsav("574") & "" & dao & "搜索|<a href='newli.asp?act=1&amp;sid="&sidd&"'>最新</a>|<a href='newli.asp?act=2&amp;sid="&sidd&"'>热销</a>|<a href='viewshopp.asp?sid="&sidd&"'>购物车</a>" & we0 & "" & hr & "") 
if name="" then
        errs=""&we&"输入错误，关键字不能为空！"&we0&""
end if
if lied=-1 or mon1=-1 or mon2=-1 then
        sql="select id,name,smoney from qingtian_shop where name like '%"&name&"%'"
elseif lied<>"0" then
        mon1=int(mon1)
        mon2=int(mon2)
        sql="select id,name,smoney from qingtian_shop where feid="&lied&" and smoney<"&mon2&"  and smoney>"&mon1&" and name like '%"&name&"%'"
elseif lied="0" then
        mon1=int(mon1)
        mon2=int(mon2)
        sql="select id,name,smoney from qingtian_shop where smoney<"&mon2&" and smoney>"&mon1&" and name like '%"&name&"%'"
elseif mon1<mon2 then
        errs=""&we&"输入错误，价格区间格式错误！"&we0&""
end if

	
	IF len(errs)=0 then
                Rs.Open Sql,conn,1,1
		if not (rs.bof and rs.eof)  then
				Rs.PageSize = 15	'一页N条记录
				IF Not IsEmpty(Page) Then
					IF Not IsNumeric(Page) Then		'判断Page是否为数字
						Page=1
					Else
						Page=Cint(Page)		'转换成短整形Integer
					End IF
					IF Page > Rs.PageCount Then
						Rs.AbsolutePage = Rs.PageCount	'设置当前显示页等于最后一页
					ElseIF Page <= 0 Then
						Rs.AbsolutePage = 1		'设置当前页等于第一页
					Else
						Rs.AbsolutePage = Page	'如果大于零,显示当前页等于接收的页数
					End IF
				Else
					Rs.AbsolutePage = 1
				End IF
				Page = Rs.AbsolutePage


		For i=1 to  Rs.PageSize
		If Rs.Eof Then
			exit For
		End If
%>
			<%
dat=i+(page-1)*Rs.PageSize
dat1=dat mod 2
if dat1=0 then
                       %><%=we%><%=dat%>.<a href="fileve.asp?id=<%=rs(0)%>&amp;sid=<%=sidd%>"><%=qingtian.utf8(rs(1))%>/销售价:<%=rs(2)%></a>[<a href="pay.asp?id=<%=rs(0)%>&amp;sid=<%=sidd%>">订购</a>]<%=we0%>
<%
else
%>
<%=sou%><%=dat%>.<a href="fileve.asp?id=<%=rs(0)%>&amp;sid=<%=sidd%>"><%=qingtian.utf8(rs(1))%>/销售价:<%=rs(2)%></a>[<a href="pay.asp?id=<%=rs(0)%>&amp;sid=<%=sidd%>">订购</a>]<%=we0%>
<%
end if
	 	Rs.MoveNext
	  	Next
                If Page > 1 then
     		    Response.Write dao
                end if
       
    		'分页
    		If Page < rs.PageCount Then
    		    Response.Write("<a href='search.asp?name="&server.URLEncode(name)&"&amp;mon1="&mon1&"&amp;mon2="&mon2&"&amp;lied="&lied&"&amp;page=" & Page + 1 & "&amp;sid="&sidd&"'>下一页</a>")
    		End If
       
    		If Page > 1 And Page < rs.PageCount Then
    		    Response.Write("|")
    		End If
        
    		If Page > 1 Then
    		    Response.Write("<a href='search.asp?name="&server.URLEncode(name)&"&amp;mon1="&mon1&"&amp;mon2="&mon2&"&amp;lied="&lied&"&amp;page=" & Page - 1 & "&amp;sid="&sidd&"'>上一页</a>" & we0 & "")
    		Elseif rs.PageCount >1 then
    		   Response.Write("" & we0 & "")
    		End If
            
    		Randomize()
    
    		If rs.PageCount > 10 Then


%>
		<%=book%>
		<%


    		End If
                If Page > 1 then
     		    Response.Write("" & hr & "" & we & "[第"&Page&"/总"&rs.PageCount&"页/"&rs.RecordCount&"条]" & we0 & "")
                end if
                else
                Response.Write("" & we & "暂无商品" & we0 & "")
		end if
		Rs.close
                set rs=nothing
else
             Response.Write errs
end if
Response.Write("" & qingtian.qingsav("573") & "" & hr & "" & sou & "<a href='search.asp?sid="&sidd&"'>返回继续搜索商品</a>" & we0 & "") 


end Function
%>
